#include <bits/stdc++.h>

using namespace std;
class Solution {
   public:
    int vowelStrings(vector<string>& words, int left, int right) {
        int mask = 0;
        int ret = 0;
        mask += 1 << ('a' - 'a');
        mask += 1 << ('e' - 'a');
        mask += 1 << ('i' - 'a');
        mask += 1 << ('o' - 'a');
        mask += 1 << ('u' - 'a');
        for (int i = left; i <= right; i++) {
            if ((mask & (1 << (words[i][0] - 'a'))) == 0 ||
                (mask & (1 << (words[i][words[i].size() - 1] - 'a'))) == 0) {
                    continue;
            }
            ret++;
        }
        return ret;
    }
};